#include "stdio.h"
#include "SDL/SDL.h"

int main(int argc, char *argv[]){

    int done=1,x=0,y=0;


SDL_Surface *image,*noir,*blanc;
SDL_Rect src, dest;
SDL_Rect srcn, destn;
SDL_Rect srcb, destb;
    SDL_Surface *ecran = NULL;
    SDL_Event event;
    SDL_Rect position;
    SDL_MOUSEMOTION;


    SDL_Init(SDL_INIT_VIDEO);

    ecran = SDL_SetVideoMode(1200, 680, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));

image = SDL_LoadBMP("image/tab.bmp");
if (image == NULL) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
noir= SDL_LoadBMP("image/noir.bmp");
if (noir == NULL) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
blanc= SDL_LoadBMP("image/blanc.bmp");
if (blanc == NULL) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 255, 255, 255));
SDL_SetColorKey(noir, SDL_SRCCOLORKEY, SDL_MapRGB(noir->format, 255, 255, 255));
SDL_SetColorKey(blanc, SDL_SRCCOLORKEY, SDL_MapRGB(noir->format, 0, 0, 0));
src.x =0;                srcn.x = 0;             srcb.x = 0;
src.y = 0;                srcn.y = 0;             srcb.y = 0;
src.w = image->w;         srcn.w = image->w;      srcb.w = image->w;
src.h = image->h;         srcn.h = image->h;      srcb.h = image->h;
dest.x = 0;             destn.x = 210;          destb.x = 280;
dest.y = 0;             destn.y = 0;          destb.y = 280;
dest.w = image->w;        destn.w = image->w;     destb.w = image->w;
dest.h = image->h;        destn.h = image->h;     destb.h = image->h;

 SDL_WM_SetCaption("OTHELLO", NULL);

while(done){
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
done = 0;
break;
case SDL_KEYDOWN:
{
if (event.key.keysym.sym == SDLK_ESCAPE)
done = 0;
break;
case SDL_MOUSEBUTTONUP:
        destn.x = event.motion.x-30;
        destn.y = event.motion.y-30;
            break;
}
}
}
SDL_BlitSurface(image, &src, ecran, &dest);
SDL_BlitSurface(noir, &srcn, ecran, &destn);
SDL_BlitSurface(blanc, &srcb, ecran, &destb);
SDL_Flip(ecran);}
SDL_FreeSurface(image);
SDL_FreeSurface(noir);
SDL_FreeSurface(blanc);

    return 0;
}
